package com.hnevc.cnlizhimaomxbc;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MeActivity extends AppCompatActivity {
    private ListView list_lv;
    private ImageView shouye_tu;
    private ImageView diancang_tu;
    private ImageView dingdan_tu;
    private String[] titles = {"邀请有奖","消息通知","问题反馈","关于我们"};
    private int[] icons = {R.mipmap.liwu,R.mipmap.ling,R.mipmap.erji,R.mipmap.gantanhao};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_me);
        initView();
        initData();
        initEvent();
        list_lv = findViewById(R.id.list_lv);
        list_lv.setAdapter(new MyBaseAdaper());
    }
    class MyBaseAdaper extends BaseAdapter{

        @Override
        public int getCount() {
            return titles.length;
        }

        @Override
        public Object getItem(int position) {
            return titles[position];
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = View.inflate(MeActivity.this,R.layout.list_item_activity,null);
            TextView title = (TextView)view.findViewById(R.id.tv2);
            ImageView imageView = (ImageView)view.findViewById(R.id.tu01);
            title.setText(titles[position]);
            imageView.setBackgroundResource(icons[position]);
            return view;
        }
    }
    private void initView(){
        shouye_tu = (ImageView)findViewById(R.id.shouye_tu);
        diancang_tu = (ImageView)findViewById(R.id.diancang_tu);
        dingdan_tu = (ImageView) findViewById(R.id.dingdan_tu);

    }
    private void initData(){

    }
    private void initEvent(){
        dingdan_tu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MeActivity.this, DinActivity.class);
                startActivityForResult(intent,1);
            }
        });
        diancang_tu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MeActivity.this, EatActivity.class);
                startActivityForResult(intent,1);
            }
        });
        shouye_tu.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MeActivity.this,HomeActivity.class);
                startActivityForResult(intent,1);
            }
        });

    }
}
